package cn.sonui.onlinechat.utils;

import cn.sonui.onlinechat.bean.MessageInfo;

import java.util.ArrayList;
import java.util.List;

public class MessageList {
    private final List<MessageInfo> list = new ArrayList<>();

    public MessageInfo getMessage(Integer id){
        return list.size() > id ? list.get(id) : null;
    }

    public Integer addMessage(MessageInfo msg){
        int id;
        synchronized (list){
            list.add(msg);
            id = list.size() - 1;
        }
        return id;
    }

    public Integer getMessageSize(){return list.size();}
}
